/*
Author: Maciej Oczko
Date: December 2011
*/

#ifndef TEXTURE_MGR_H
#define TEXTURE_MGR_H

#include <cassert>
#include "../MemoryManager/Singleton.h"
#include "ResourceMgr.h"

#ifdef _DIRECTX
#include "DXTexture.h"
#define TEXTYPE DXTexture
#endif

#ifdef _OPENGL
#include "GLTexture.h"
#define TEXTYPE GLTexture
#endif

class TextureMgr : public ResourceMgr, public Singleton<TextureMgr>
{
public:
	TextureMgr(unsigned p_NumberOfResources);
	~TextureMgr();

	//void SetNumberOfResources(unsigned p_NumberOfResources);

	// transforms identifier into file path based on resource type
	// and loads the resource
	// clears rarely used resources if needed
	RHANDLE Load(std::wstring p_Identifier);

	// unloads all resources
	void ReleaseAll() { Unload<TEXTYPE>(); }
	
	Texture* GetTexture(RHANDLE p_Handle) { return m_MemoryManager->dereference<TEXTYPE>(p_Handle); }
};

#endif